//
//  NSString+HXBase64.m
//  UI24-加密（MD5）
//
//  Created by 韩旭 on 16/8/16.
//  Copyright © 2016年 lanou. All rights reserved.
//

#import "NSString+HXBase64.h"

@implementation NSString (HXBase64)

//编码
- (NSString *)stringWithBase64 {
    
    NSData *data = [self dataUsingEncoding:NSUTF8StringEncoding];
    //    把字符串转化成NSData
NSString *string = [data base64EncodedStringWithOptions:NSDataBase64Encoding64CharacterLineLength];
    return string;
}

//解码


- (NSData *)base64StringWithData {
    return [[NSData alloc] initWithBase64EncodedString:self options:NSDataBase64DecodingIgnoreUnknownCharacters];
    
}
- (NSString *)Base64WithString {

//    根据base64字符串， 生成NSData
    NSData *base64Data = [self base64StringWithData];
//    NSData 进行Base64, 转化字符串
    NSString *orginString = [[NSString alloc] initWithData:base64Data encoding:NSUTF8StringEncoding];
    return orginString;
}
@end
